package com.mini.handler;

import com.mini.MiniRowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MiniBeanListHandler<T> extends MiniAbstractListHandler<T> {

    private final MiniRowProcessor convert;
    private final Class<T> type;

    public MiniBeanListHandler(Class<T> type) {
        this(type,ROW_PROCESSOR);
    }
    public MiniBeanListHandler(Class<T> type, MiniRowProcessor convert) {
        this.convert = convert;
        this.type = type;
    }

    @Override
    public T handleRow(ResultSet resultSet) throws SQLException {
        return convert.toBean(resultSet,type);
    }
}
